<!DOCTYPE html>
<html>
  <head>
    <title>jslint4java command line usage</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link href="jslint4java.css" type="text/css" rel="stylesheet" />
    <link href="prettify.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="prettify.js"></script>
  </head>
  <body>
    <h1>Using jslint4java on the command line</h1>

    <p>jslint4java can be run as an executable jar file:</p>

    <pre class="prettyprint"><span class="nocode">$ java -jar jslint4java-${project.version}.jar
Usage: jslint4java [options]
 file.js ...
  Options:
        --adsafe     If adsafe rules should be enforced
        --bitwise    If bitwise operators should be allowed
        --browser    If the standard browser globals should be predefined
        --confusion  If types can be used inconsistently
        --continue   If the continuation statement should be tolerated
        --css        If css workarounds should be tolerated
        --debug      If debugger statements should be allowed
        --devel      If logging should be allowed (console, alert, etc.)
        --encoding   Specify the input encoding
        --eqeq       If == should be allowed
        --es5        If es5 syntax should be allowed
        --evil       If eval should be allowed
        --forin      If for in statements need not filter
        --fragment   If html fragments should be allowed
        --help       Display usage information
                     Default: false
        --indent     The indentation factor
        --jslint     Specify an alternative version of jslint.js
        --maxerr     The maximum number of errors to allow
        --maxlen     The maximum length of a source line
        --newcap     If constructor names capitalization is ignored
        --node       If node.js globals should be predefined
        --nomen      If names may have dangling _
        --on         If html event handlers should be allowed
        --passfail   If the scan should stop on first error
        --plusplus   If increment/decrement should be allowed
        --predef     The names of predefined global variables
        --regexp     If the . should be allowed in regexp literals
        --report     Display report in different formats: plain, xml, junit,
                     checkstyle and report
        --rhino      If the rhino environment globals should be predefined
        --safe       If use of some browser features should be restricted
        --sloppy     If the 'use strict'; pragma is optional
        --sub        If all forms of subscript notation are tolerated
        --timeout    Maximum number of seconds JSLint can run for
                     Default: 0
        --undef      If variables can be declared out of order
        --unparam    If unused parameters should be tolerated
        --vars       If multiple var statements per function should be allowed
        --white      If sloppy whitespace is tolerated
        --widget     If the yahoo widgets globals should be predefined
        --windows    If ms windows-specific globals should be predefined

using jslint version 2011-06-11
</span></pre>

    <p>The list of options is (mostly) derived from the
      <a href="apidocs/com/googlecode/jslint4java/Option.html">Option</a> enum.  For fuller
      documentation of each option, see the
      <a href="http://www.jslint.com/lint.html">jslint web site</a>.</p>

    <p>You must pass a number of javascript files on the command line.  For each one,
      jslint4java will produce a list of errors on stdout.  If any errors are found,
      an exit code of 1 will be returned.</p>

    <p>Sample error output:</p>

    <pre class="prettyprint"><span class="nocode">$ cat dodgy.js
someVar = 42
$ java -jar jslint4java-${project.version}.jar dodgy.js
jslint:dodgy.js:0:12:Missing semicolon.
$
</span></pre>

    <p>The fields are colon separated and consist of:</p>

    <ol>
      <li>The fixed string "jslint"</li>
      <li>The filename</li>
      <li>The line number</li>
      <li>The column number</li>
      <li>The error</li>
    </ol>

    <p>Most command line flags are boolean.  If you wish to pass a value to a flag
      (e.g. <code>--indent</code>), it must be separated by whitespace.  For example:</p>

      <pre class="prettyprint"><span class="nocode">$ cat happy.js
var x;
if (x) {
  x = 42;
}
$ java -jar jslint4java-${project.version}.jar --white happy.js
jslint:happy.js:2:2:Expected 'x' to have an indentation of 4 instead of 2.
$ java -jar jslint4java-${project.version}.jar --white --indent 2 happy.js
$
</span></pre>

    <p>
      To pass a list of predefined global variables, give a comma separated
      list of names to <code>--predef</code>, e.g.
    </p>

    <pre class="prettyprint"><span class="nocode">$ cat globals.js
foo(bar(42));
$ java -jar jslint4java-${project.version}.jar --undef globals.js
jslint:globals.js:1:1:'foo' is not defined.
jslint:globals.js:1:5:'bar' is not defined.
$ java -jar jslint4java-${project.version}.jar --undef --predef foo,bar globals.js
$
</span></pre>

    <h3 id="options">Additional Options</h3>

    <p id="option-help">
      <code>--help</code> produces the usual display of information.
    </p>

    <p id="option-encoding">
      If your file is in an alternative encoding, that can be specified
      with the <code>--encoding</code> flag.  This value is passed directly
      to <a href="http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/api/java/nio/charset/Charset.html#forName(java.lang.String)">Charset.forName()</a>,
      so any encoding supported by your Java VM is allowed.  If no encoding
      is specified, the platform default is used.
      <span style="color:#eee">
        &lt;subliminal&gt;Use UTF-8!  Use UTF-8!&lt;/subliminal&gt;
      </span>
    </p>

    <p id="option-report">
      You may request an alternative form of reporting using the
      <code>--report</code> flag.
    </p>

    <table>
      <tr>
        <th><code class="nobreak">--report</code></th>
        <th>Description</th>
      </tr>
      <tr>
        <td>plain</td>
        <td>
          A more verbose plain text format, which shows the line of code on
          which the error occurs, as well as highlighting the position of the
          error within that line.
        </td>
      </tr>
      <tr>
        <td>junit</td>
        <td>
          Produce an XML file similar to that of the
          <a href="http://ant.apache.org/manual/Tasks/junit.html">ant junit task</a>.
          This is a good choice for integrating with third-party systems.
        </td>
      </tr>
      <tr>
        <td>report</td>
        <td>
          JSLint will produce an HTML
          <a href="http://www.jslint.com/lint.html#report">report</a> on your
          code, including a list of all functions.
        </td>
      </tr>
      <tr>
        <td>xml</td>
        <td>
          A custom XML format, with one element per error.  You should prefer
          the JUnit output format if possible.
        </td>
      </tr>
    </table>

    <p id="option-jslint">
      You can specify an alternative <code>jslint.js</code> in case the version
      supplied doesn't suit you (for example there is a newer version available).
      To use another jslint, specify <code>--jslint /some/where/jslint.js</code>
      on the command line.
    </p>

    <script type="text/javascript">prettyPrint()</script>
  </body>
</html>
